package part1.api.io.iotest;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
//        File file = new File("a.txt");
//        FileInputStream fis = new FileInputStream(file);
//        byte[] data = new byte[(int) file.length()];
//        fis.read(data);
//        String line = new String(data, StandardCharsets.UTF_8);
//        System.out.println(line);
//        fis.close();

//        File file = new File("ab.txt");
//        FileInputStream fis = new FileInputStream(file);
//        byte[] data = new byte[(int) file.length()];
//        fis.read(data);
//        String line = new String(data, StandardCharsets.UTF_8);
//        System.out.println(line);
//        fis.close();


        File file = new File("ab.txt");
        FileInputStream fis = new FileInputStream(file);
        byte[] data = new byte[(int) file.length()];
        fis.read(data);
        System.out.println(Arrays.toString(data));
        String line = new String(data, StandardCharsets.UTF_8);
        System.out.println(line);
        fis.close();
    }
}
